import { defineStore } from 'pinia';

// 智能体管理 Store
export const useAgentStore = defineStore('agent', () => {
    // 当前选中的智能体
    const currentAgent = ref<any>({
        "id": "1921838545713623041",
        "name": "总结类智能体",
        "addr": "http://192.168.1.151:8109/v1/chat-messages",
        "keyStr": "app-E6JC7coIqP6ik4MT0rzQqiuq",
        "createDate": "2025-05-12 16:03:10"
    });

    // 设置当前智能体
    const setCurrentAgent = (agent: any) => {
        currentAgent.value = agent;
    };

    // 获取当前智能体的 keyStr
    const getCurrentAgentKey = () => {
        return currentAgent.value?.keyStr; // 默认值
    };

    // 清空当前智能体
    const clearCurrentAgent = () => {
        currentAgent.value = null;
    };

    return {
        currentAgent: readonly(currentAgent),
        setCurrentAgent,
        getCurrentAgentKey,
        clearCurrentAgent,
    };
}, {
    persist: true,
});